/*
 * Test program for 3D Helmholtz solvers
 * Tests both FDM and FEM implementations
 * FDM now supports half single precision (16-bit floating point)
 */

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <mpi.h>

// Function declarations from the two solver files
extern int test_helmholtz_fdm_3d();
extern int test_helmholtz_fem_3d();

int main(int argc, char** argv) {
    printf("=== 3D Helmholtz Solvers Comparison ===\n");
    printf("Testing both FDM (half precision) and FEM implementations\n\n");
    
    // Initialize MPI (required for some parts of the codebase)
    MPI_Init(&argc, &argv);
    
    clock_t start_time, end_time;
    double cpu_time_used;
    
    // Test FDM solver
    printf("Testing Finite Difference Method (FDM) Solver with Half Precision:\n");
    printf("===================================================================\n");
    start_time = clock();
    int fdm_result = test_helmholtz_fdm_3d();
    end_time = clock();
    cpu_time_used = ((double) (end_time - start_time)) / CLOCKS_PER_SEC;
    printf("FDM Solver completed in %.4f seconds\n", cpu_time_used);
    printf("FDM Result: %s\n\n", fdm_result == 0 ? "PASSED" : "FAILED");
    
    // Test FEM solver
    printf("Testing Finite Element Method (FEM) Solver:\n");
    printf("============================================\n");
    start_time = clock();
    int fem_result = test_helmholtz_fem_3d();
    end_time = clock();
    cpu_time_used = ((double) (end_time - start_time)) / CLOCKS_PER_SEC;
    printf("FEM Solver completed in %.4f seconds\n", cpu_time_used);
    printf("FEM Result: %s\n\n", fem_result == 0 ? "PASSED" : "FAILED");
    
    // Summary
    printf("=== Summary ===\n");
    printf("FDM Solver (Half Precision): %s\n", fdm_result == 0 ? "PASSED" : "FAILED");
    printf("FEM Solver (Double Precision): %s\n", fem_result == 0 ? "PASSED" : "FAILED");
    printf("Overall: %s\n", (fdm_result == 0 && fem_result == 0) ? "ALL TESTS PASSED" : "SOME TESTS FAILED");
    
    MPI_Finalize();
    
    return (fdm_result == 0 && fem_result == 0) ? 0 : 1;
} 